from flask import Blueprint,jsonify
from utils.db import db1
resource_bp = Blueprint('resource',__name__)
from comm import get_data

@resource_bp.route('/getresource')
def getresource():
    sql = "select * from resource"

    res = db1.find_all(sql)

    return jsonify({'code':200,'list':res})



@resource_bp.route('/addresource',methods=["POST"])
def addresource():
    data = get_data()

    sql = "insert into resource(id,name,url,type,pid) values(0,'%s','%s',%d,%d)" %  (data['name'],data['url'],int(data['type']),int(data['pid']))

    db1.update(sql)

    return jsonify({'code':200,'mes':'添加成功'})









